Working version... need to have more elegant design...