Fixed bug with basis generation