restructure functions into subdirectory. custom login added