move alley code to separate file