Fixed a bug. Made it more idiomatic