Cleaned it up a bit as suggested by @jeromsar