cleaning + added optimization