re-construct the codes to be more easy to use