Moved helper functionality into seperate file