Moved code to separate library