cleaning up syntax and bugs