Fix spectrum calculation