move somw code from the core gem