reindented and cleaned up unused vars