Refactor code and add basic *lab function wrapper