fix naming and some logic