fixed some problems and broken code
restore fixed