changed the code to be close to Cyan's python