added spectrum example and refactored a bit