cleaned up code fixed more bugs