cleaned up code a bit. added 1413