Edited for correctness and style