Cleaned the code a bit. Now working.