Implemented changes suggested by @SamSaffron