Reverted to currently working code to start from a solid foundation