shortern the code of take and put