Cleaned up code. It might work.