added realpath and setup function