Move environment setup to shell function