rearrange the code. removed unused items.