almost finished, few bugs