cleaning up and bug fixing