first version with basic functionality revised