[michael] transfer codes to their own file
[michael] merge