Tested and working code

Testing and working code pushed.