merge code from utils
cleanup