Changed and removed some redundant code. If this doesn't work, let me know.